package cn.leetcode;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @version 1.0.0
 * @Copyright: NHDC
 * @package: PACKAGE_NAME
 * @author: Leonidax
 * @date: 2020/7/18
 */
class Topic{
    public int[] plusOne(int[] digits) {
        for(int i=digits.length-1; i>=0; i--){
            if(digits[i] == 9){
                digits[i] = 0;
            }else{
                digits[i]++;
                return digits;
            }
        }
        int[] plus = new int[digits.length+1];
        plus[0] = 1;
        for(int i=1;i<=digits.length;i++){
            plus[i] = 0;
        }
        return plus;
    }

}

/**
 * @author leonidax
 */
public class Acm {
    public static void main(String[] args){
        Topic topic = new Topic();
        int[] nums = new int[]{9};
        String a = "   ";
        String b = "llo";
        System.out.println(topic.plusOne(nums).toString());
    }

}
